refactor(api): extend #206 type-safety to security (#359 batch 8)#384
Merged
refactor(api): extend #206 type-safety to security (#359 batch 8)#384
Conversation
…tch 8) Apply the #206 playbook to security.ts. 25 `as never` casts removed. src/lib/api/security.ts: + 9 read adapters: adaptDashboard / adaptScore / adaptScan / adaptScanList / adaptFinding / adaptFindingList / adaptPolicy / adaptScanConfig / adaptRepoSecurity / adaptTriggerScanResponse — each normalizes SDK's `?: T | null` to local type's `: T | null`. + 4 write adapters: adaptTriggerRequest / adaptCreatePolicyRequest / adaptUpdatePolicyRequest / adaptUpsertConfigRequest — explicit field forwarding so a future local-type addition surfaces at typecheck. + adaptScore synthesizes total_findings from severity counts (the SDK ScoreResponse omits it). + assertData on every successful read. Drift handling: - SDK PolicyResponse has fields the local ScanPolicy doesn't model (max_artifact_age_days, min_staging_hours, require_signature). Those belong to lifecycle policies, not security policies — the SDK conflates the two via shared CreatePolicyRequest/UpdatePolicyRequest types (same root cause as the SDK type leak in batch 1's lifecycle.ts). The adapter intentionally drops them. Tests rewritten with realistic SDK fixtures (typed as Sdk* for compile- time drift detection). New regression tests: - Score: last_scan_at undefined → null - listScans: nullable fields normalization - acknowledgeFinding: body shape forwarding - getRepoSecurity: null config / null score handling - createPolicy / updatePolicy: body shape forwarding CHANGELOG entry under [Unreleased] / Changed. Closes #359 (partial — batch 8 of N). Remaining: sso (large, final).
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #359 (partial — batch 8). Same playbook for
src/lib/api/security.ts. 25as neverremoved; zero retained casts.13 adapters total (9 read, 4 write) covering the full security graph: Dashboard, Score, Scan, Finding, Policy, ScanConfig, RepoSecurity.
Acceptance criteria
as unknown as/as neverin changed filesTest plan
npm test— 2085/2085npm run lint— 0 errorsnpm run build— succeeds (TypeScript + Next prerender clean)Remaining
sso (large, final) — last batch.
🤖 Generated with Claude Code